SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO



CREATE VIEW clv_cajas
AS

SELECT	mov.cd_transaccion, mov.nu_transaccion, mov.fe_transaccion,
	mov.cd_caja, caj.nm_caja, mov.cd_unidad_monetaria, mon.nm_unidad_monetaria,
	mov.nu_ptovta, mov.fe_devengamiento, mov.de_movimiento, mov.st_conciliado,
	mov.cd_estado_trans, mov.im_cotizacion, tra.tp_mov_caja,
	im_ingreso =case tra.tp_deb_cre when 'D' then mov.im_total else 0 end,
	im_egreso =case tra.tp_deb_cre when 'C' then mov.im_total else 0 end
FROM	cld_mov_caja mov
	JOIN wad_transacciones tra ON tra.cd_transaccion =mov.cd_transaccion
	JOIN ccd_cajas caj ON caj.cd_caja =mov.cd_caja
	JOIN wad_unidades_monetarias mon ON mon.cd_unidad_monetaria =mov.cd_unidad_monetaria



GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

